<template>
    <el-tooltip placement="top" content="复制单个数据分析模板">
        <el-button :type="type" size="small" @click="onCopyDsTemplate()" icon="Document">复制数据模板</el-button>
    </el-tooltip>
</template>

<script setup>
/**
 * 复制数据模板按钮
 * 用途：菜单栏/工具/选号设置/复制数据模板
 */
import { ElMessageBox } from 'element-plus';
import { copyText } from '@/utils/Utils';

const { data, type } = defineProps({
    data: Object,
    type:String
})
const onCopyDsTemplate = () => {
    let text = 
`{
    "order": [
        ""
    ],
    "orderSum": [
        0
    ],
    "sumRange": "${data.sumRange || ''}",
    "trend": "${data.trend || ''}",
    "frontRange": "${data.frontRange || ''}",
    "backRange": "${data.backRange || ''}",
    "frontIncludes": "${data.frontIncludes || ''}",
    "frontExcludes": "${data.frontExcludes || ''}",
    "backIncludes": "${data.backIncludes || ''}",
    "backExcludes": "${data.backExcludes || ''}",
    "cart": {
        "01": "${data.cart[0] || ''}",
        "02": "${data.cart[1] || ''}",
        "03": "${data.cart[2] || ''}",
        "04": "${data.cart[3] || ''}",
        "05": "${data.cart[4] || ''}",
        "06": "${data.cart[5] || ''}",
        "07": "${data.cart[6] || ''}"
    },
    "cartCombin": {
        "rowsCount": 0,
        "drawalCount": 0,
        "bonus": 0,
        "bestPrize": ""
    },
    "cartMergeZone": {
        "count": 0,
        "drawalCount": 0,
        "frontCount": 0,
        "frontDrawalCount": 0,
        "backCount": 0,
        "backDrawalCount": 0
    },
    "cartMergeAll": {
        "count": 0,
        "drawalCount": 0
    },
    "choosePool": "${data.poolText || ''}",
    "comment": ""
}`;
    copyText(text);
    ElMessageBox.alert('复制成功');
}

</script>